package com.java.simple.smallspring.bean;

import com.java.simple.smallspring.beans.factory.BeanClassLoaderAware;
import com.java.simple.smallspring.beans.factory.BeanFactory;
import com.java.simple.smallspring.beans.factory.BeanFactoryAware;
import com.java.simple.smallspring.beans.factory.BeanNameAware;
import com.java.simple.smallspring.beans.factory.DisposableBean;
import com.java.simple.smallspring.beans.factory.InitializingBean;
import com.java.simple.smallspring.context.ApplicationContext;
import com.java.simple.smallspring.context.ApplicationContextAware;
import lombok.Getter;
import lombok.Setter;

/**
 * @author zhoujunlin
 * @date 2022年08月17日 17:03
 * @desc
 */
@Getter
@Setter
public class UserService implements BeanNameAware, BeanClassLoaderAware, ApplicationContextAware, BeanFactoryAware, InitializingBean, DisposableBean {

    private ApplicationContext applicationContext;
    private BeanFactory beanFactory;

    private String uId;
    private String company;
    private String location;
    //private UserDao userDao;
    private IUserDao userDao;

    public String selectUserInfo() {
        return userDao.queryUserName(uId) + ",公司：" + company + ",地点：" + location;
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("执行：UserService.destroy");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("执行：UserService.afterPropertiesSet");
    }

    public void setBeanFactory(BeanFactory beanFactory) {
        this.beanFactory = beanFactory;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    @Override
    public void setBeanName(String beanName) {
        System.out.println("Bean Name is:" + beanName);
    }

    @Override
    public void setBeanClassLoader(ClassLoader classLoader) {
        System.out.println("Bean ClassLoader is:" + classLoader);
    }
}
